package com.traffic.api.exception;

import javax.ws.rs.core.Response;

/**
 * api对外自定义异常
 * @author Guoxing
 *
 */
public class ApiBizException extends RuntimeException {
	private static final long serialVersionUID = -5185383075331558879L;
	private Response response;

	public ApiBizException() {
		this(null, Response.Status.INTERNAL_SERVER_ERROR);
	}

	public ApiBizException(Response response) {
		this(null, response);
	}

	public ApiBizException(int status) {
		this(null, status);
	}

	public ApiBizException(Response.Status status) {
		this(null, status);
	}

	public ApiBizException(Throwable cause) {
		this(cause, Response.Status.INTERNAL_SERVER_ERROR);
	}

	public ApiBizException(Throwable cause, Response response) {
		super(cause);
		if (response == null)
			this.response = Response.serverError().build();
		else
			this.response = response;
	}

	public ApiBizException(Throwable cause, int status) {
		this(cause, Response.status(status).build());
	}

	public ApiBizException(Throwable cause, Response.Status status) {
		this(cause, Response.status(status).build());
	}

	public Response getResponse() {
		return this.response;
	}
}